﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace Presentation
{
    public partial class UserControlButton : UserControl
    {
        public UserControlButton()
        {
            InitializeComponent();
            _MouseEnter = false;
            _MouseLeave = true;
            _bClick = false;
   
        }
        protected Bitmap _Picture;
        [Browsable(true)]
        public Bitmap Picture
        {
            get { return _Picture; }
            set { _Picture = value; Invalidate(); }
        }

        protected Bitmap _PictureMouseEnter;
        [Browsable(true)]
        public Bitmap PictureMouseEnter
        {
            get { return _PictureMouseEnter; }
            set { _PictureMouseEnter = value; Invalidate(); }
        }
        protected bool _MouseEnter;
        protected bool _MouseLeave;

        protected bool _bClick;
        //protected bool _MouseLeftDown;

        private void UserControlButtonClose_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            if (_MouseLeave)
            {
                if (Picture != null)
                {
                    //g.DrawImage(Picture, (Width - Picture.Width) / 2, (Height - Picture.Width) / 2, Picture.Width, Picture.Height);
                    g.DrawImage(Picture, 0, 0, Width, Height);
                }
            }
            else
                if (_MouseEnter)
                {
                    if (PictureMouseEnter != null)
                    {
                        //g.DrawImage(PictureMouseEnter, (Width - PictureMouseEnter.Width) / 2, (Height - PictureMouseEnter.Width) / 2, PictureMouseEnter.Width, PictureMouseEnter.Height);
                        g.DrawImage(PictureMouseEnter, 0, 0, Width, Height);
                    }
                }
        }

        private void UserControlButtonClose_MouseEnter(object sender, EventArgs e)
        {
            _MouseEnter = true;
            _MouseLeave = false;
            Invalidate();
        }

        private void UserControlButtonClose_MouseLeave(object sender, EventArgs e)
        {
            _MouseEnter = false;
            _MouseLeave = true;
            Invalidate();
        }

        private void UserControlButtonClose_MouseClick(object sender, MouseEventArgs e)
        {
            //if (e.Button == MouseButtons.Left)
            //{
            //    if (MouseLeftClick != null)
            //        MouseLeftClick(sender, e);
            //}  
        }

    }
}
